package shuai.action;

import shuai.controller.UserController;
import shuai.model.User;

public class RegistAction extends BaseAction {
	private String uname;
	private String upwd;
	private int uage;
	private String usex;
	private String uphone;
	
	public void validateRegist(){
		if(uname!=null && uname.trim().length()==0){
			addFieldError("uname",getText("error.uname.required"));			
		}
		if(upwd!=null && upwd.trim().length()==0){
			addFieldError("upwd", getText("error.upwd.required"));
		}
	}
	public String execute(){
		UserController userController=new UserController();
		User user=new User(uname,upwd,uage,usex,uphone);
		int flag=userController.userRegist(user);
		if(flag==1){
			getSession().setAttribute("user", user);
			return SUCCESS;
		}else{
			return ERROR;
		}		
	}
	
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public String getUpwd() {
		return upwd;
	}
	public void setUpwd(String upwd) {
		this.upwd = upwd;
	}
	public int getUage() {
		return uage;
	}
	public void setUage(int uage) {
		this.uage = uage;
	}
	public String getUsex() {
		return usex;
	}
	public void setUsex(String usex) {
		this.usex = usex;
	}
	public String getUphone() {
		return uphone;
	}
	public void setUphone(String uphone) {
		this.uphone = uphone;
	}
	
	
}
